﻿var portaluserno = getCookie ('portaluserno')
var configInfo=InitialParameter("/Config.json")
var modelApis = getBaseplatformPort () 
//获取当前机构上下级机构
function getORGTree(orgid, type) {
    var thisResult = null;
    type = type == "up" ? "up" : "down"; 
    $.ajax({
        type: "post",
        async: false,
        url: modelApis + 'dept/getAllDepts',
        data: //发送到服务器的参数
            {
                orgid: orgid,
                treetype: 'down'
            },
        datatype: "json",
        success: function (result) {
            thisResult = JSON.parse(result).data;
        },
        error: function (err) {
            if (err.status == 405)
                top.location.href = '/';
        }
    });
    return thisResult;
}
//检查机构关系
function checkORGLevel(userOrg, otherOrg) {
    var result = null;
    var orgLength = 0;
    if (userOrg.length > otherOrg.length) {//当前用户是所选机构的下级
        orgLength = otherOrg.length;
        if (userOrg.slice(0, orgLength) == otherOrg) {//直属
            return "upper";
        }
        else {
            return "peer";
        }
    }
    else if (userOrg.length == otherOrg.length) {//当前用户跟所选机构平级
        if (userOrg == otherOrg) {
            return "self";
        }
        else {
            return "peer";
        }
    }
    else {//当前用户是所选机构的上级
        orgLength = userOrg.length;
        if (otherOrg.slice(0, orgLength) == userOrg) {//直属
            return "lower";
        }
        else {
            return "peer";
        }
    }
}
